add
Insert a value at the specified index. Any elements previously occurring at and after the specified index have their indices increased by 1, and the size of the list increases by 1.
Note that for a list my_list
:
my_list.add(my_list.size(), x)
"appends"x
to the end of the listmy_list.add(my_list.size() + 1, x)
throws an exception
Note also that my_list.add(my_list.size(), x)
is equivalent to my_list.add(x)
(inherited from collection<T>
).
Return
true
Since
0.6.0
Parameters
The index at which to add the element.
The value to add.
Throws
if the index is out of bounds
Append an element to the end of this collection.
The element is not added if this collection does not allow duplicates and the element is already contained in this collection.
Return
true
if the element was added, false
otherwise
Since
0.6.0
Parameters
the element to add